//
//  SegmentViewController.swift
//  banTang
//
//  Created by 王磊 on 17/4/12.
//  Copyright © 2017年 王磊. All rights reserved.
//

import UIKit
import SwiftyJSON
class SegmentViewController: UIViewController {

    
    var dataSource = Array<TopicModel>()
    lazy var tableView: UITableView = {
        let table = UITableView.init(frame: CGRect.init(x: 0, y: 0, width: SCREEN_WIDTH, height: SCREEN_HEIGHT), style: UITableViewStyle.plain)
        table.delegate = self
        table.dataSource = self
        let view = UIView.init(frame: CGRect.init(x: 0, y: 0, width: SCREEN_WIDTH, height: SCREEN_HEIGHT))
        view.backgroundColor = UIColor.white
        table.tableHeaderView = view
        table.scrollIndicatorInsets = UIEdgeInsets.init(top: 182, left: 0, bottom: 0, right: 0)
        return table
    }()
    override init(nibName nibNameOrNil: String?,bundle nibBundleOrNil: Bundle?){
    super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
        self.view.addSubview(self.tableView)
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    override func viewDidLoad() {
        super.viewDidLoad()
       
        
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        
    }
}
extension SegmentViewController: UITableViewDelegate,UITableViewDataSource{
        func numberOfSections(in tableView: UITableView) -> Int {
            return 1
        }
        func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
            return self.dataSource.count
        }
        func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
            
            let cellID = "cell"
            
            var cell = tableView.dequeueReusableCell(withIdentifier: cellID) as? SegCell
            
            if cell == nil {
                cell = SegCell.init(style: .default, reuseIdentifier: cellID)
            }
            
            cell?.sendModel(model: self.dataSource[indexPath.row])
            
            return cell!
        }
        func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
            return 300
        }
        func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
            cell.separatorInset = UIEdgeInsets.zero
            cell.layoutMargins = UIEdgeInsets.zero
        }

        
        
    
    
    }
   

